package com.dcy.znoa.common.exception;

import com.dcy.znoa.common.enums.ResultCode;

public class BusinessException extends Exception{

    private static final long serialVersionUID = -5317007026578376164L;

    /**
     * 错误码
     */
    private String errorCode;
    /**
     * 错误描述
     */
    private String errorMsg;
    /**
     * @param errorCode
     * @param errorMsg
     */
    public BusinessException(String errorCode, String errorMsg) {
        super(String.format("BusinessException{errorCode:%s, errorMsg:%s}", errorCode, errorMsg));
        this.errorCode = errorCode;
        this.errorMsg = errorMsg;
    }

    public BusinessException(ResultCode resultCode) {
        super(String.format("BusinessException{errorCode:%s, errorMsg:%s}", resultCode.code(), resultCode.message()));
        this.errorCode = resultCode.getCode();
        this.errorMsg = resultCode.getMessage();
    }

    public String getErrorCode() {
        return errorCode;
    }

    public String getErrorMsg() {
        return errorMsg;
    }

}